package com.ibs.hadoop.hbase.service.impl;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.ibs.hadoop.hbase.bean.QueryBean;
import com.ibs.hadoop.hbase.bean.UseComplaintBaseClass;
import com.ibs.hadoop.hbase.console.PropertiesEnumKey;
import com.ibs.hadoop.hbase.console.UserComplaintFlow;
import com.ibs.hadoop.hbase.service.UserComplaintService;
import com.ibs.hadoop.hbase.service.complaint.UserComplaintDataQuery;
import com.ibs.hadoop.hbase.service.run.ExecQueryManger;
import com.ibs.hadoop.hbase.util.IOutils;
import com.ibs.hadoop.hbase.util.PropertiesUtils;

/**
 * 查询
* 源文件名：UserComplaintServiceImpl.java
* 文件版本：1.0.0
* 创建作者：Think
* 创建日期：2016年11月1日
* 修改作者：Think
* 修改日期：2016年11月1日
* 文件描述：TODO
* 版权所有：Copyright 2016 zjhz, Inc. All Rights Reserved.
*/
public class UserComplaintLocalTestServiceImpl implements UserComplaintService {

    /**
     * 本地文件缓存操作
    * @字段说明 fileProcess
    */
    private LocalCacheFileProcess fileProcess = new LocalCacheFileProcess();

    @Override
    public Map<String, List<UseComplaintBaseClass>> queryUserComplaint(String imsi, String startTime, String endTime,
            List<String> flows) {

        String filePath = PropertiesUtils.getInstance().getValue(PropertiesEnumKey.USER_COMPLAINT_WRITE_PATH.getKey());

        Map<String, List<UseComplaintBaseClass>> mapData = fileProcess.readObjectFile(filePath + "cache.obj");

        return mapData;
    }

    public static void main(String[] args) {
        UserComplaintService service = new UserComplaintLocalTestServiceImpl();

        List<String> flowList = new ArrayList<>();

        flowList.add("ATTACH");
        flowList.add("DETACH");
        flowList.add("TAU");
        flowList.add("GET");
        flowList.add("POST");
        flowList.add("SND_MMS");
        flowList.add("RCV_MMS");
        flowList.add("DNS");

        long startTime = System.currentTimeMillis();

        Map<String, List<UseComplaintBaseClass>> list = service.queryUserComplaint("999999999999999", "20161102",
                "20161102", flowList);
        // Map<String, List<UseComplaintBaseClass>> list =
        // service.queryUserComplaint("999999999999999", "20161101", "20161101",
        // flowList);

        long endTime = System.currentTimeMillis();

        System.out.println("用时:" + (endTime - startTime) / 1000.0f + "秒");

        System.out.println("最终结果:" + list.size());
    }
}
